package com.noocodecommit.wicket.jquery.plugin.ui.magnifier;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;

import com.noocodecommit.wicket.jquery.TemplatePage;
import com.noocodecommit.wicket.stuff.jquery.JQCore;
import com.noocodecommit.wicket.stuff.jquery.plugin.chili.JQChili;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.magnifier.JQMagnifier;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.magnifier.OnMagnifyClickBehavior;
import com.noocodecommit.wicket.stuff.jquery.plugin.ui.tabs.JQTabs;

public class MagnifierPage extends TemplatePage
{

	private static final long serialVersionUID = 1L;
	private final JQTabs tabContainer;

	public MagnifierPage()
	{
		super();
		JQCore.init(this);
		this.setupChili();

		tabContainer = new JQTabs("tab-container");
		tabContainer.setOutputMarkupId(true);
		add(tabContainer);

		JQMagnifier magnifier0 = new JQMagnifier("magnifier0");
		tabContainer.add(magnifier0);

		/**
		 * 
		 */
		JQMagnifier magnifier1 = new JQMagnifier("magnifier1");
		tabContainer.add(magnifier1);

		final Label output1 = new Label("output1");
		output1.setOutputMarkupId(true);
		tabContainer.add(output1);

		magnifier1.add(new OnMagnifyClickBehavior()
		{
			public void onClick(AjaxRequestTarget target)
			{
				String msg = String.format("clicked magnifier item");
				output1.setModel(new Model(msg));
				target.addComponent(output1);
			}
		});

		JQChili chili1 = new JQChili("chili1");
		add(chili1);
		this.bindChiliCode(chili1, this.getClass(), "html");

		JQChili chili2 = new JQChili("chili2");
		add(chili2);
		this.bindChiliCode(chili2, this.getClass(), "java");

		JQCore.get().bindOnDocumentReadyFunction();
	}
}
